
// #pragma once
#ifndef RTMP_INCLUDE_MESSAGE_H_
#define RTMP_INCLUDE_MESSAGE_H_
#include "./../../public_module/public_module_define.h"
#include <cstdint>
#include <vector>

struct RtmpHeader
{
    RtmpHeader();
    ~RtmpHeader();
    int PrintRtmpHeader(char * buffer);
    uint8_t m_format;
    uint8_t m_chunk_stream; 
    uint32_t m_timestamp;
    uint32_t m_calc_timestamp;
    uint32_t m_body_size;
    uint8_t  m_type_id;
    uint32_t m_stream_id;    
};

struct RtmpBodyAttr
{
    int m_chunk_size{0};
    uint8_t m_media_attr_data{0};
};

struct RtmpBody
{
    RtmpBody();
    ~RtmpBody();
    int PrintRtmpBody(char * buffer);
    std::vector<AmfValue*> m_amf_value_vec;
    std::vector<uint8_t> m_data;
    RtmpBodyAttr m_attr_data{};
};

struct RtmpMessage
{
    RtmpMessage();
    ~RtmpMessage();
    std::string PrintRtmpMessage();
    std::string CommandString();
    int NumberId();
    AmfObject * Object();
    std::string UserPass(int i = 1);
    void PushAmfValue(AmfValue * value);
    void CopyRtmpHeader(const RtmpHeader & header);
    RtmpHeader m_header;
    RtmpBody   m_body;
};

enum RtmpConnectState
{
    EmRtmpConnectInit = 0x00,
    EmRtmpConnectHandShake, 
    EmRtmpConnectSendC0C1,
    EmRtmpConnectRecvC0C1 , 
    EmRtmpConnectInitFinish,
    EmRtmpConnectConnectCmd,
    EmRtmpConnectCreateStreamCmd,
    EmRtmpConnectPlayCmd,
    EmRtmpConnectFailed   
};

struct RtmpStreamData
{
	int m_stream_id{0};
	int m_record_body_size{0};
	int64_t m_timestamp{0};		// calculated timestamp
	int64_t m_delta_time{0};	// delta timestamp
	int m_type_id{0};
};

#endif // RTMP_INCLUDE_MESSAGE_H_
